package com.example.administrator.text.Framgnet;

import android.app.Fragment;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.FragmentManager;
import android.support.v4.widget.SwipeRefreshLayout;
import com.example.administrator.text.R;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.Gson;
import org.apache.log4j.Logger;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import adapter.RecyclerHome;
import app.MyApplication;
import butterknife.Bind;
import butterknife.ButterKnife;
import data.SharedPreferencesUtils;
import entity.HomeZhuYe;
import util.AgentIp;
import util.GreenTreeNetworkUtil;
import util.HomeUtil;
import util.LogUtil;
import util.NetUtils;
import util.NetWorkstateUtil;
import util.RequestDataCallback;
import util.StringUtil;
import util.TimeUtil;
import util.Url;
import util.listComparator.HomeZhuYeButonn;
import util.listComparator.HomeZhuYeButonnImage;
import util.listComparator.HomeZhuYeHeadImage;
import util.listComparator.HomeZhuYeHeadText;
import util.listComparator.HomeZhuYeMiddle;
import view.CustomViewPager;
import view.HomeBottonLLayout;
import view.MySwipeRefreshLayout;
import view.diaLogView.CrowdRetunDialog;
import view.diaLogView.RetunDialog;
import view.diaLogView.UploadDialog;

/**
 *首页
 */
public class HomeFragment extends Fragment{
    private FragmentManager mFragmentManager;
    public  String mFwq;
    private String mToken;                              //求情需要的参数
    public static final String ID = "ID";              //服务器
    public static final String TOKEN = "TOKEN";
    public static  final String ARG_PARAM1 = "mFWQString";
    private int mType,mNetworkingType;                         //创建几个HomeBottonLLayout。代表第几个view适配器  联网对应集合的下标
    private List<HomeZhuYe.HotSiteModelsBean> mGridaButton;
    private List<HomeZhuYe.BannerModelsBean.TextModelsBean> mTextModels; //头部侧滑文字
    private List<HomeZhuYe.BannerModelsBean.PicModelsBean> mPicModels;  //头部侧滑的图片
    private List<HomeZhuYe.FeatureModelsBean> mFetureModelsBean;       //中间的图标数据
    private List<HomeZhuYe.HotSiteModelsBean> mHotSitModelsBean;      //底部的图标数据
    private List<HomeZhuYe.AdModelsBean> mAdModelsBean;              //底部的图片
    private HomeBottonLLayout mHomeBottonLLayout;
    private RecyclerHome mRecyclerHome,mRecyclerHomeButton;                         //中间的适配器
    private HashMap<String,Object> mMap;
    private UploadDialog mUploadDialog;
    private RetunDialog mRetunDialog;
    private MySwipeRefreshLayout mSwipeRefreshLayout;
    private View mView;
    private Logger mLogger = Logger.getLogger(HomeFragment.class);
    private Handler mHandlerHome = new Handler();

    @Bind(R.id.viewpager_home)        CustomViewPager mCustomViewPager;       //首页的侧滑控件
    @Bind(R.id.recyler_home)          RecyclerView mRecyclerView;            //中间的视图
    @Bind(R.id.linear_home_botton)    LinearLayout mLinearLayoutButton;     //底部的块加图的视图
    @Bind(R.id.recyler_home_botton)   RecyclerView mRecyclerViewBotton;    //最底部的图片集
    @Bind(R.id.iv_fragment_fail)      ImageView mIVfail;     //加载失败时显示的图
    @Bind(R.id.textView_fragment)     TextView mTextView;

    public HomeFragment(){
         LogUtil.eE("","HomeFragment()");
    }

    public static HomeFragment newInstance(String token) {
        HomeFragment fragment = new HomeFragment();
        Bundle args = new Bundle();
        args.putString(TOKEN,token);
        fragment.setArguments(args);
        LogUtil.eE("","newInstance()");
        return fragment;
    }

    @Override public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mToken = getArguments().getString(TOKEN);
            LogUtil.eE("","onCreate()");
        }
    }

    @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                       final Bundle savedInstanceState) {
        mView = inflater.inflate(R.layout.fragment_home, container, false);
        ButterKnife.bind(this, mView);
        LogUtil.eE("","onCreateView()");
        return mView;
    }

    @Override public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        HomeUtil.getHemeUtilNew().getStatusBar(getActivity(),null);//状态栏
        initData();
        LogUtil.eE("","onViewCreated()");
        EventBus.getDefault().register(this);
        pullRefresh();
        initTime();
    }


    /**
     * 加载数据
     */
    public void initData() {

        if(mUploadDialog == null){
            mUploadDialog = new UploadDialog(getActivity(),"加载中");
            mUploadDialog.show();
        }else {
            mUploadDialog.show();
        }
        mCustomViewPager.setWhewther(false);

        if(mTextModels !=null){mTextModels.clear();} if(mPicModels !=null){mPicModels.clear();}

        if(mFetureModelsBean !=null){mFetureModelsBean.clear();} if(mHotSitModelsBean !=null){mHotSitModelsBean.clear();}

        if(mAdModelsBean !=null){mAdModelsBean.clear();}

        mMap = new HashMap<>();
        String id = (String) SharedPreferencesUtils.getParam(getActivity(),HomeUtil.mUseridDB,"");
        mMap.put("userid",id);
        mMap.put("token", mToken);
        mMap.put("areaid",MyApplication.getApp().getSiteAreaid());
        if(getString(R.string.app_name).equals("牛欢WiFi")){
            mMap.put("appType",2);
        }else if(getString(R.string.app_name).equals("NewFi")){
            mMap.put("appType",1);
        }
        String stringJson = StringUtil.getStringUtilNew().hashMapToJson(mMap); //参数包
        long time = StringUtil.getStringUtilNew().getTimeCurrent();
        String stirngSign = StringUtil.getStringUtilNew().getSign(Url.mStirngUrl_pageHome,stringJson,mToken,id,time);
        Map map = StringUtil.getStringUtilNew().getMapNew(getActivity(),stringJson,mToken,id,Url.mStirngUrl_pageHome,stirngSign,time);
        mLogger.info("initData（）-->加载数据--fwq"+MyApplication.getApp().getFWQString()+"stringJson"+stringJson);
        GreenTreeNetworkUtil.getInstance().doPost(getActivity(),MyApplication.getApp().getFWQString(),1,map,new RequestDataCallback() {
            @Override public void onSuccess(String response) {
                Gson gson = new Gson();
                LogUtil.eE("",response);
                mIVfail.setVisibility(View.GONE);
                mUploadDialog.dismiss();
                HomeZhuYe homezhuye = gson.fromJson(response,HomeZhuYe.class);
                if(homezhuye.getCode() == 1){
                    mTextModels = homezhuye.getBannerModels().getTextModels();
                    mPicModels = homezhuye.getBannerModels().getPicModels();
                    mFetureModelsBean = homezhuye.getFeatureModels();
                    mHotSitModelsBean = homezhuye.getHotSiteModels();
                    mAdModelsBean = homezhuye.getAdModels();
                    Collections.sort(mTextModels,new HomeZhuYeHeadText());
                    Collections.sort(mPicModels,new HomeZhuYeHeadImage());
                    Collections.sort(mFetureModelsBean,new HomeZhuYeMiddle());
                    Collections.sort(mHotSitModelsBean,new HomeZhuYeButonn());
                    Collections.sort(mAdModelsBean,new HomeZhuYeButonnImage());
                    initViewPagerHead();
                    initViewPagerMiddle();
                    initViewPagerBotton();
                    setHomeBttonImageView();
                }else if(homezhuye.getCode() == -1){
                    Toast.makeText(getActivity(),getString(R.string.FWQ), Toast.LENGTH_SHORT).show();
                }else if(homezhuye.getCode() == -2){
                    CrowdRetunDialog crowdRetunDialog = new CrowdRetunDialog(getActivity());
                    crowdRetunDialog.show();
                }
            }

            @Override public void onFailure(Throwable error) {
                mIVfail.setVisibility(View.VISIBLE);
                mUploadDialog.dismiss();
                mIVfail.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        initData();
                    }
                });
                StringUtil.getStringUtilNew().getExceptionCode(getActivity(), error.toString());
            }
        });
    }

    /**
     * fragmentManager
     */
    public void getFManager(FragmentManager fragmentManager){
        this.mFragmentManager = fragmentManager;
    }

    /**
     * 初始化头部ViewPager
     */
    public void initViewPagerHead() {

        mCustomViewPager.setFragmentManager(mFragmentManager);
        mCustomViewPager.setWhewther(true);
        LogUtil.eE("IMAGEPIC","initViewPagerHead()..."+mPicModels.size()+"");
        mCustomViewPager.loadDatas(mTextModels,mPicModels);

    }

    /**
     * 中间的ViewPager
     */
    public void initViewPagerMiddle() {

        for (int i = 0; i <mFetureModelsBean.size(); i++) {
            if(mFetureModelsBean.get(i).getType().equals("shangwang")){
                mNetworkingType = i;
            }
        }

        if(NetUtils.getInstance(getActivity()).getNetWorkTeyt() !=0){
            LogUtil.eE("",".............................!0");
            mLogger.info("initData（）-->isNetWorkstate"+AgentIp.newInstance(getActivity()).isNetWorkstate());
              if (AgentIp.newInstance(getActivity()).isNetWorkstate()){
                  if(MyApplication.getApp().getSiteAreaid() != 0){
                      HomeZhuYe.FeatureModelsBean fm = getFM(mFetureModelsBean.get(mNetworkingType).getPic());
                      fm.setText("断网");
                      mFetureModelsBean.set(mNetworkingType,fm);
                      initViewPagerMiddle1();
                      NetWorkstateUtil.getInstance().setNetWorkstae(true);
                  }else {
                      NetWorkstateUtil.getInstance().setNetWorkstae(false);
                      HomeZhuYe.FeatureModelsBean fm = getFM(mFetureModelsBean.get(mNetworkingType).getPic());
                      fm.setText("上网");
                      mFetureModelsBean.set(mNetworkingType,fm);
                      initViewPagerMiddle1();
                  }
              }else {
                 NetWorkstateUtil.getInstance().setNetWorkstae(false);
                 HomeZhuYe.FeatureModelsBean fm = getFM(mFetureModelsBean.get(mNetworkingType).getPic());
                 fm.setText("上网");
                 mFetureModelsBean.set(mNetworkingType,fm);
                 initViewPagerMiddle1();
              }

        }else {
            LogUtil.eE("",".............................0");
            HomeZhuYe.FeatureModelsBean fm = getFM(mFetureModelsBean.get(mNetworkingType).getPic());
            fm.setText("上网");
            mFetureModelsBean.set(mNetworkingType,fm);
            initViewPagerMiddle1();
        }
    }

    /**
     * 中间的ViewPager
     */
    public void initViewPagerMiddle1(){
        GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(),4);
        mRecyclerView.setLayoutManager(gridLayoutManager);
        mRecyclerHome = new RecyclerHome(getActivity(), mFetureModelsBean,null,null,1);
        //mRecyclerHome.getItemViewType(1);
        //SpaceItemDecoration spaceItemDecoration = new SpaceItemDecoration(getActivity(),1,mRecyclerHome);
        mRecyclerView.setAdapter(mRecyclerHome);
        mRecyclerHome.setOnItemClickListener(new RecyclerHome.OnRecyclerViewItemClickListener() {
            @Override
            public void onItemClick(int position, String type) {
                if(type.equals("shangwang")){
                    int net = NetUtils.getInstance(getActivity()).getNetWorkTeyt();
                    mLogger.info("接收到上网的点击事件--->onItemClick--（）");
                    switch (net){
                        case 0:
                            mRetunDialog = new RetunDialog(getActivity(),"",2,true);
                            mRetunDialog.show();
                            break;
                        case 1:
                            String urlString = MyApplication.getApp().getFWQString();
                            if(urlString.equals(Url.getUrlNew().getAppIP())){
                                getJudge();
                            }else {
                                getJudge();
                            }
                            break;
                        case 3:
                            mRetunDialog = new RetunDialog(getActivity(),"",1,true);
                            mRetunDialog.show();
                            break;
                    }
                }
            }
        });
    }

    /**
     * 底部的ViewPager
     */
    public void initViewPagerBotton() {

        if(mHotSitModelsBean.size()>=15){
            final int pagertype = mHotSitModelsBean.size() % 15;
            mType = pagertype == 0 ? mHotSitModelsBean.size() / 15 : (mHotSitModelsBean.size() / 15) + 1;//获取view 的个数
            int grid = 0;
            for (int i = 0; i < mType; i++) {
                mGridaButton = new ArrayList<>();
                mHomeBottonLLayout = new HomeBottonLLayout(getActivity());
                for (int j = 0; j < 15; j++) {
                    if (grid > mHotSitModelsBean.size() - 1)
                        break;
                    mGridaButton.add(mHotSitModelsBean.get(grid));
                    grid++;
                }
                mHomeBottonLLayout.setViewData(mGridaButton,mAdModelsBean);
                LinearLayout.LayoutParams linearLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                mHomeBottonLLayout.setLayoutParams(linearLayout);
                mLinearLayoutButton.addView(mHomeBottonLLayout);
            }
        }else {
            mHomeBottonLLayout = new HomeBottonLLayout(getActivity());
            mHomeBottonLLayout.setViewData(mHotSitModelsBean,mAdModelsBean);
            mLinearLayoutButton.addView(mHomeBottonLLayout);
        }

        if(mHotSitModelsBean.size() == 0){
            mTextView.setVisibility(View.GONE);
        }

    }



    /**
     * 加载底部的图片
     */
    private void setHomeBttonImageView(){
        List<HomeZhuYe.AdModelsBean> modelsBean = new ArrayList<>();
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        mRecyclerViewBotton.setLayoutManager(linearLayoutManager);

        if(mHotSitModelsBean.size()<=15 && mHotSitModelsBean.size() !=0){
            for (int i = 0; i <mAdModelsBean.size(); i++) {
                if(i >0){
                    modelsBean.add(mAdModelsBean.get(i));
                }
            }
        }else if(mHotSitModelsBean.size()>15){
            for (int i = 0; i <mAdModelsBean.size(); i++) {
                if(i>=mType){
                    modelsBean.add(mAdModelsBean.get(i));
                }
            }
        }
        mRecyclerHomeButton = new RecyclerHome(getActivity(),mFetureModelsBean,modelsBean,null,2);
        mRecyclerViewBotton.setAdapter(mRecyclerHomeButton);
    }

    @Override public void onDestroy() {
        super.onDestroy();

        LogUtil.eE("","fr....onDestroy");
        if(mHandlerHome !=null){mHandlerHome.removeCallbacksAndMessages(null);} //移除消息队列中所有消息和所有的Runnable来避免内存泄漏

        if(mGridaButton !=null){mGridaButton.clear();}

        if(mTextModels !=null){mTextModels.clear();}

        if(mPicModels !=null){mPicModels.clear();}

        if(mHotSitModelsBean !=null){mHotSitModelsBean.clear();}

        if(mAdModelsBean !=null){mAdModelsBean.clear();}

        mCustomViewPager.getOnDestroy();
        if(mRetunDialog !=null){mRetunDialog.dismiss();}

        EventBus.getDefault().unregister(this);//取消注册
    }

    /*** 订阅事件FirstEvent*/
    @Subscribe
    public void onEventMainThread(String string){
        mLogger.info("onEventMainThread... "+string);
        if(NetUtils.getInstance(getActivity()).getNetWorkTeyt() !=0){
            if(string !=null && !string.equals("")){
                if(string.equals("联网成功")){
                    HomeZhuYe.FeatureModelsBean featureModelsBean= getFM(mFetureModelsBean.get(mNetworkingType).getPic());
                    featureModelsBean.setText("断网");
                    if(mRecyclerHome !=null){mRecyclerHome.getChanged(mNetworkingType,featureModelsBean);}

                }else if(string.equals("断网成功")){
                    HomeZhuYe.FeatureModelsBean featureModelsBean= getFM(mFetureModelsBean.get(mNetworkingType).getPic());
                    featureModelsBean.setText("上网");
                    if(mRecyclerHome !=null){mRecyclerHome.getChanged(mNetworkingType,featureModelsBean);}
                }
            }
        }
    }

    public void getJudgeIP(final int type){
        String stringJson ="{}"; //参数包
        long time = StringUtil.getStringUtilNew().getTimeCurrent();
        String stirngSign = StringUtil.getStringUtilNew().getSign(Url.mStirngVersion_isAlive,stringJson,"null","0",time);
        Map map = StringUtil.getStringUtilNew().getMapNew(getActivity(),stringJson,"null","0",Url.mStirngVersion_isAlive,stirngSign,time);
        if(type == 0 ){
          mFwq = (String) SharedPreferencesUtils.getParam(getActivity(),HomeUtil.mFWQ,"");
        }
        mLogger.info("测试代理....getJudgeIP()--->type"+type+"mFwq...."+mFwq);
        GreenTreeNetworkUtil.getInstance().doPost(getActivity(),mFwq,1500,map,new RequestDataCallback() {
            @Override public void onSuccess(String response) {
                try {
                    mLogger.info("getJudgeIP()--->onSuccess()+String--"+response);
                    JSONObject jsonObject = new JSONObject(response);
                    if (jsonObject.getInt("code") == 1) {
                        mUploadDialog.getStringShow("联网中");
                        MyApplication.getApp().setFWQString(mFwq);
                        SharedPreferencesUtils.setParam(getActivity(),HomeUtil.mFWQ,mFwq);
                        NetWorkstateUtil.getInstance().getNetworking(getActivity(),mUploadDialog,HomeUtil.ZHUYE);
                    }else {
                        mUploadDialog.dismiss();
                        Toast.makeText(getActivity(),getString(R.string.FWQ),Toast.LENGTH_SHORT).show();}

                } catch (JSONException e) {e.printStackTrace();}
            }

            @Override public void onFailure(Throwable error) {
                mLogger.info("getJudgeIP()--->onFailure()去走portal或+Throwable--"+error);
                AgentIp.newInstance(getActivity()).getIp(new AgentIp.OnAgentIpItemClickListener() {
                    @Override
                    public void onItemClick(String fwq) {
                        mLogger.info("getJudgeIP()--->网页获取的地址"+"String--"+fwq);
                        if(fwq.equals("没有查到")){
                            Toast.makeText(getActivity(),"没有查找到代理服务器",Toast.LENGTH_SHORT).show();
                            mUploadDialog.dismiss();
                        }else {
                            mUploadDialog.getStringShow("联网中");
                            MyApplication.getApp().setFWQString(fwq);
                            if(!fwq.equals(MyApplication.mFWQIP)){
                                SharedPreferencesUtils.setParam(getActivity(), HomeUtil.mFWQ,fwq);
                                NetWorkstateUtil.getInstance().getNetworking(getActivity(),mUploadDialog,HomeUtil.ZHUYE);
                            }else {
                                Toast.makeText(getActivity(),"没有查找到代理服务器",Toast.LENGTH_SHORT).show();
                                mUploadDialog.dismiss();
                            }

                        }
                    }
                });
            }});
    }

    /**
     * 下拉刷新
     */
    private void pullRefresh(){

        mSwipeRefreshLayout = (MySwipeRefreshLayout) mView.findViewById(R.id.swipe_home);
        mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
                android.R.color.holo_green_light,
                android.R.color.holo_orange_light,
                android.R.color.holo_red_light);
        mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
            LogUtil.eE("","onRefresh.......");
                HomeUtil.getHemeUtilNew().domainUtil(getActivity(),1000,new HomeUtil.OnHomeUtilClickListener() {
                    @Override
                    public void onItemClick(String type) {
                        if(MyApplication.getApp().getSiteAreaid() !=0 ){
                            if(type.equals("ok")){
                                LogUtil.eE("","onRefresh.......");
                                if(!mFetureModelsBean.get(mNetworkingType).getText().equals("断网")){
                                    HomeZhuYe.FeatureModelsBean featureModelsBean= getFM(mFetureModelsBean.get(mNetworkingType).getPic());
                                    featureModelsBean.setText("断网");
                                    if(mRecyclerHome !=null){mRecyclerHome.getChanged(mNetworkingType,featureModelsBean);}
                                }

                                HomeUtil.getHemeUtilNew().getHandlerNew().postDelayed(new Runnable() {
                                    @Override
                                    public void run() {
                                        mSwipeRefreshLayout.setRefreshing(false);
                                    }
                                },800);
                            }else {
                                if(mFetureModelsBean.get(mNetworkingType).getText().equals("断网")){
                                    HomeZhuYe.FeatureModelsBean featureModelsBean= getFM(mFetureModelsBean.get(mNetworkingType).getPic());
                                    featureModelsBean.setText("上网");
                                    if(mRecyclerHome !=null){mRecyclerHome.getChanged(mNetworkingType,featureModelsBean);}
                                }
                                mSwipeRefreshLayout.setRefreshing(false);
                            }
                        }else {
                            mSwipeRefreshLayout.setRefreshing(false);
                        }
                    }
                });
            }
        });
    }

    /**
     *用域名连是否可以连通
     */
    public void getJudge(){

        if(mUploadDialog == null){
            mUploadDialog = new UploadDialog(getActivity(),"连接中");
            mUploadDialog.show();
        }else {
            mUploadDialog.show();
        }
        String stringJson ="{}"; //参数包
        long time = StringUtil.getStringUtilNew().getTimeCurrent();
        String stirngSign = StringUtil.getStringUtilNew().getSign(Url.mStirngVersion_isAlive,stringJson,"null","0",time);
        Map map = StringUtil.getStringUtilNew().getMapNew(getActivity(),stringJson,"null","0",Url.mStirngVersion_isAlive,stirngSign,time);
        LogUtil.eE("",StringUtil.getStringUtilNew().getTimeInstance());
        mLogger.info("判断网络是否可用--->stringJson--"+stringJson+"fwq"+MyApplication.mFWQIP);
        GreenTreeNetworkUtil.getInstance().doPost(getActivity(),MyApplication.mFWQIP,1000,map,new RequestDataCallback() {
            @Override public void onSuccess(String response) {
                try {
                    mUploadDialog.dismiss();
                    JSONObject jsonObject = new JSONObject(response);
                    mLogger.info("onSuccess（）--String"+response);
                    if (jsonObject.getInt("code") == 1) {
                        final RetunDialog retunDialog = new RetunDialog(getActivity(),"",5,true);
                        retunDialog.show();
                        mHandlerHome.postDelayed(new Runnable() {
                            @Override public void run() {
                                retunDialog.dismiss();
                            }
                        },1000);
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                    getJudgeIP(0);
                }
            }

            @Override public void onFailure(Throwable error) {
                mLogger.info("onFailure（）....Throwable"+error);
                getJudgeIP(0);
            }
        });
    }

    /**
     *生成一个 FeatureModelsBean
     */
    private HomeZhuYe.FeatureModelsBean getFM(String pic){
        HomeZhuYe.FeatureModelsBean fm = new HomeZhuYe.FeatureModelsBean();
        fm.setPic(pic);
        fm.setType("shangwang");
        fm.setOrder(mNetworkingType+1);
        fm.setUrl("");
        return fm;
    }

    /**
     * 计时看是否需要上传日志
     */
    private void initTime() {
        if(Url.getUrlNew().isLogUploadsState()){
            TimeUtil.getInstance(getActivity()).getShowTime("LogUploads");
        }
    }

}
